package com.cheer.vo;

import com.cheer.enums.TitleEnum;
import com.google.common.collect.Maps;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Data
public class ApplicantExportVO {

    private static Map<String, String> headerAlias = Maps.newLinkedHashMap();

    static{
        headerAlias.put("number","序号");
        headerAlias.put("applicantName","集体名称");
        headerAlias.put("contactPerson","负责人");
        headerAlias.put("phoneAccount","号长手机号码");
        headerAlias.put("backupAccount","备用账号");
        headerAlias.put("title","荣誉等级");
        headerAlias.put("awarded","状态");
    }

    private String number;

    private String applicantName;

    private String contactPerson;

    private String phoneAccount;

    private String backupAccount;

    private String title;

    private String awarded;

    public static Map<String, String> getHeaderAlias(){
        return headerAlias;
    }

    public static List<ApplicantExportVO> buildList(List<ApplicantPageVO> applicantPageVOS) {
        List<ApplicantExportVO> applicantExportVOS = new ArrayList<>();
        for (int i = 0; i < applicantPageVOS.size(); i++) {
            ApplicantPageVO applicantPageVO = applicantPageVOS.get(i);
            ApplicantExportVO applicantExportVO = new ApplicantExportVO();
            applicantExportVO.setNumber(String.valueOf(i + 1));
            applicantExportVO.setApplicantName(applicantPageVO.getApplicantName());
            applicantExportVO.setContactPerson(applicantPageVO.getContactPerson());
            applicantExportVO.setPhoneAccount(applicantPageVO.getPhoneAccount());
            applicantExportVO.setBackupAccount(applicantPageVO.getBackupAccount());
            if (applicantPageVO.getTitle() != TitleEnum.NO.getType()) {
                TitleEnum titleEnum = TitleEnum.getByType(applicantPageVO.getTitle());
                if (titleEnum != null) {
                    applicantExportVO.setTitle(titleEnum.getDescription());
                }
            }
            if (applicantPageVO.getAwarded()) {
                applicantExportVO.setAwarded("已获得");
            } else {
                applicantExportVO.setAwarded("未获得");
            }
            applicantExportVOS.add(applicantExportVO);
        }
        return applicantExportVOS;
    }

}
